﻿using FineUI;
using SysManage.BLL;
using System;
using ZHDJ.Data.Models.Common;
using ZHDJ.PersonalCenter.BLL;

namespace ZHDJ.PersonalCenter.Module.PhotoWall
{
    public partial class PhotoWallCommentEdit : PageBase
    {
        #region ViewPower

        /// <summary>
        /// 本页面的浏览权限，空字符串表示本页面不受权限控制
        /// </summary>
        public override string ViewPower
        {
            get
            {
                return "";
            }
        }

        private string RelationID
        {
            get
            {
                return this.Request["PhotoWallID"] ?? "";
            }
        }
        #endregion

        #region Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
                BindGrid();
            }
        }

        private void LoadData()
        {
            btnClose.OnClientClick = ActiveWindow.GetHideReference();

            Grid1.PageSize = ConfigHelper.PageSize;

            BindGrid();
        }

        private void BindGrid()
        {
            var ds = PartyComment.GetCommentData(Grid1.PageIndex, Grid1.PageSize, this.RelationID);

            Grid1.RecordCount = Convert.ToInt32(ds.Tables[1].Rows[0][0]);
            Grid1.DataSource = ds.Tables[0];
            Grid1.DataBind();
        }
        #endregion

        #region Events
        protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
        {
            Grid1.PageIndex = e.NewPageIndex;
            BindGrid();
        }
        #endregion
    }
}